﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyCommerce.Presentation.Orders.IViews;
using MyCommerce.Business.Stores;
using Innova.Microfinanzas.BusinessEntities;

namespace MyCommerce.Presentation.Orders.Presenters
{
    public class NewProductDetailPresenter
    {
        private INewProductDetail pViewToPresent;

        public NewProductDetailPresenter(INewProductDetail vView)
        {
            pViewToPresent = vView;
            pViewToPresent.OnDeployDetail += new EventHandler(pViewToPresent_OnDeployDetail);
            pViewToPresent.OnLoadView += new EventHandler(pViewToPresent_OnLoadView);
        }

        void pViewToPresent_OnLoadView(object sender, EventArgs e)
        {
            ProductManager productMgr = new ProductManager();
            pViewToPresent.ColProductsLoad = productMgr.GetProducts();
        }

        void pViewToPresent_OnDeployDetail(object sender, EventArgs e)
        {
            ProductPriceManager priceMgr = new ProductPriceManager();
            ProductPrice objPrice = priceMgr.GetProductPriceByProductAndMoneyAndSupplier(pViewToPresent.ObjProductSelected.IdProduct, pViewToPresent.IdMoneyLoad, pViewToPresent.IdSupplierLoad);
            if (objPrice != null)
                pViewToPresent.DeployNewDetail(objPrice);
        }
    }
}
